﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace  LINQToolKit.Douban.Entities
{
    public sealed class Book : Subject
    {
        private const string ISBN10_KEY = "isbn10";
        private const string ISBN13_KEY = "isbn13";
        private const string PAGES_KEY = "pages";
        private const string TRANSLATOR_KEY = "tranlator";
        private const string PRICE_KEY = "price";
        private const string PUBLISHER_KEY = "publisher";
        private const string BINDING_KEY = "binding";
        private const string AUTHORINTRO_KEY = "author-intro";

        public string LongIsbn
        {
            get  { return base.GetAttribute(ISBN13_KEY);}
            set  { base.SetAttribute(ISBN13_KEY, value);}
        }

        public string ShortIsbn
        {
            get { return base.GetAttribute(ISBN10_KEY); }
            set { base.SetAttribute(ISBN10_KEY, value); }
        }

        public int Pages
        {
            get
            {
                string tmp = base.GetAttribute(PAGES_KEY);
                return string.IsNullOrEmpty(tmp) ? 0 : Convert.ToInt32(tmp);
            }
            set { base.SetAttribute(PAGES_KEY, value.ToString()); }
        }

        public decimal Price
        {
            get
            {
                string tmp = base.GetAttribute(PRICE_KEY);
                return string.IsNullOrEmpty(tmp) ? 0 : Convert.ToDecimal(tmp);
            }
            set { base.SetAttribute(PRICE_KEY, value.ToString()); }
        }

        public string Translator
        {
            get { return base.GetAttribute(TRANSLATOR_KEY); }
            set { base.SetAttribute(TRANSLATOR_KEY, value); }
        }

        public string AuthorIntro
        {
            get { return base.GetAttribute(AUTHORINTRO_KEY); }
            set { base.SetAttribute(AUTHORINTRO_KEY, value); }
        }

        public string Publisher
        {
            get { return base.GetAttribute(PUBLISHER_KEY); }
            set { base.SetAttribute(PUBLISHER_KEY, value); }
        }

        public string Binding
        {
            get { return base.GetAttribute(BINDING_KEY); }
            set { base.SetAttribute(BINDING_KEY, value); }
        }
    }
}
